library(RSuperMap)
library(GWmodel)
library(sp)

server = "E:/d.udb"
ds <- OpenDatasource(server, alias = "data")
dataset <- GetDataset(ds, "县区面层")
data = Query2DF(dataset)

## 固定带宽，直接计算GWR
result = gwr.basic(Q2013~A+B+C+D+E, data = data,bw = 50, kernel="gaussian",adaptive=FALSE)
result$GW.diagnostic

## 计算带宽
bw = bw.gwr(Q2013~A+B+C+D+E, data = data, approach="CV",kernel="gaussian",adaptive=FALSE)

result = gwr.basic(Q2013~A+B+C+D+E, data = data,bw = bw, kernel="gaussian",adaptive=FALSE)

# result = gwr.basic(Q2013~A+B+C+D+E, data = data, bw = 8, kernel="tricube",adaptive=TRUE)

WriteSpData(result$SDF, ds, "gwr_result_111")

CloseDatasource(ds)